<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <input id="btn" type="button" value="选择">
  <select name="" id="food">
    <option>西红柿</option>
    <option>香蕉</option>
    <option>橘子</option>
    <option>苹果</option>
    <option>梨</option>
  </select>
  <script>
    //获取各个元素
    var btn = document.getElementById("btn");
    var foods = document.getElementById("food");
    var opts = foods.getElementsByTagName("option"); 

    //给btn添加点击事件
    btn.onclick = function(){
      //随机获取一个option
      var num = Math.floor(Math.random() * opts.length);
      //改变第num个option为选中效果
      opts[num].selected = "true";

    };
  </script>
</body>
</html>